import axios from 'axios';
import { message } from 'ant-design-vue';
import router from '../router';

// 创建axios实例
const request = axios.create({
  baseURL: `${window.location.protocol}//${window.location.hostname}`,
  timeout: 15000,
  headers: {
    'Content-Type': 'application/json'
  }
});

// 请求拦截器
request.interceptors.request.use(
  config => {
    const token = localStorage.getItem('access_token');
    if (token) {
      config.headers['Authorization'] = `Bearer ${token}`;
    }
    return config;
  },
  error => {
    console.error('Request error:', error);
    return Promise.reject(error);
  }
);


export default request; 